package com.wip.reportingservice.controllers;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.http.HttpStatus;

import com.wip.reportingservice.services.domains.ListData;
import com.wip.reportingservice.services.domains.ReportData;
import com.wip.reportingservice.services.dtos.RequestDto;
import com.wip.reportingservice.services.interfaces.IDataService;
import com.wip.reportingservice.services.interfaces.IReportService;

@Controller
@RequestMapping("/Reporting")
public class Reporting {

	@Autowired
	private IReportService service;
	
	@Autowired
	private IDataService dataService;

	@RequestMapping(value = "/data", method = RequestMethod.POST)
	@ResponseStatus(HttpStatus.OK)
	public @ResponseBody
	ReportData getReportingData(@RequestBody RequestDto args) {
		// http://localhost:8080/reporting-service/Reporting/data

		 
		return service.getOtherReportNew(args.getClients(),args.getPages(),args.getLogs());
		
	}

	@RequestMapping(value = "/nfprs")
	@ResponseStatus(HttpStatus.OK)
	public @ResponseBody
	String getNineFivePercentReportString() {
		// http://localhost:8080/springtest-1.0.0-BUILD-SNAPSHOT/Reporting/nfprs

		return service.getReport();
	}

	/*
	 * @RequestMapping(value ="/nfpr") public String
	 * getNineFivePercentReport(List<String> clientList, List<String> pageList,
	 * Date startDate, Date endStart ) {
	 * 
	 * return "getNineFivePercentReport"; }
	 */
	
	@RequestMapping(value = "/allpages")
	@ResponseStatus(HttpStatus.OK)
	public @ResponseBody
	ListData getAllPages() {
		// http://localhost:8080/reporting-service/Reporting/allpages
				return dataService.getAllPages();
	}
	
	@RequestMapping(value = "/allclients")
	@ResponseStatus(HttpStatus.OK)
	public @ResponseBody
	ListData getAllClients() {
		
		// http://localhost:8080/reporting-service/Reporting/allclients
		return dataService.getAllClients();
	}
	
	@RequestMapping(value = "/alllogs")
	@ResponseStatus(HttpStatus.OK)
	public @ResponseBody
	ListData getAllLogs() {
		
		// http://localhost:8080/reporting-service/Reporting/alllogs
		return dataService.getAllLogs();
	}
	
	

}
